package com.globallogic.training.javase.easymock;

import org.apache.commons.lang.StringUtils;

public class Group implements Comparable<Group> {
	
	private String groupId;

	
	public Group(String groupId) {		
		if (groupId == null) {
			throw new IllegalArgumentException("Group ID is null");
		}
		
		if (StringUtils.isBlank(groupId)) {
			throw new IllegalArgumentException("Group ID is blank");
		}
		
		this.groupId = groupId;
	}
	
	
	public String getGroupId() {
		return groupId;
	};
	
	public String toString() {
		return "GroupID: " + groupId;
	};
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + groupId.hashCode();
		return result;
	}
	
	@Override
	public boolean equals(Object otherObject) {
		if (this == otherObject) {
			return true;
		}
		if (otherObject == null) {
			return false;
		}
		if (getClass() != otherObject.getClass()) {
			return false;
		}
		
		Group other = (Group) otherObject;
		if (this.groupId == other.groupId) {
			return true;
		}
		return false;
	}
	
	@Override
	public int compareTo(Group otherGroup) {
		String groupId = this.getGroupId();
		String otherGroupId = otherGroup.getGroupId();
		
		return groupId.compareTo(otherGroupId);
	}
	
}
